/**
 * 
 */
package org.compiere.model;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Properties;
import java.util.logging.Level;

import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;

/**
 * @author A.Yerzhanov
 * 19.06.2013
 */
public class Mhrminvoicetrip extends X_hrm_invoicetrip {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 4094746048965866861L;
	
	/**	Static Logger	*/
	private static CLogger	s_log	= CLogger.getCLogger (Mhrminvoicetrip.class);

	/**
	 * @param ctx
	 * @param hrm_invoicetrip_ID
	 * @param trxName
	 */
	public Mhrminvoicetrip(Properties ctx, int hrm_invoicetrip_ID,
			String trxName) {
		super(ctx, hrm_invoicetrip_ID, trxName);
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param ctx
	 * @param rs
	 * @param trxName
	 */
	public Mhrminvoicetrip(Properties ctx, ResultSet rs, String trxName) {
		super(ctx, rs, trxName);
		// TODO Auto-generated constructor stub
	}
	
	/**
	 * Search for entries in the invoice line 
	 * 
	 * @param C_BPartner_ID
	 * @param C_InvoiceLine_ID
	 * @return  Model invoice trip line
	 */
	public static Mhrminvoicetrip getBTripline(int C_BPartner_ID, int C_InvoiceLine_ID) {
		
		if (C_BPartner_ID == 0)
			return null;
		//
	    PreparedStatement pstmt = null;
		ResultSet rs = null;
		Mhrminvoicetrip result = null;
			
		// 
		String sql_ = "SELECT * FROM HRM_INVOICETRIP \n " +
						"WHERE ISACTIVE='Y' \n " +
							"AND AD_CLIENT_ID=" + Env.getAD_Client_ID(Env.getCtx()) + " \n " +
							"AND C_BPARTNER_ID=" + C_BPartner_ID + " \n " +
							"AND C_INVOICELINE_ID=" + C_InvoiceLine_ID;				
			try
			{
				pstmt = DB.prepareStatement(sql_,null);				
				rs = pstmt.executeQuery();	
				if(rs.next())
					result = new Mhrminvoicetrip(Env.getCtx(), rs, null);					
			}
			catch (SQLException e)
			{
				s_log.log(Level.SEVERE, "product", e);
			}
			finally
			{
				DB.close(rs, pstmt);
				rs = null; pstmt = null;
			}
			
		return result;		
	}

}
